package com.zgjkhis.modules.system.service.impl;

import com.github.pagehelper.PageInfo;
import com.zgjkhis.common.service.impl.BaseServiceImpl;
import com.zgjkhis.domain.PageResult;
import com.zgjkhis.dozer.service.IGenerator;
import com.zgjkhis.modules.registration.service.dto.ConsultDto;
import com.zgjkhis.modules.registration.service.dto.ConsultQueryCriteria;
import com.zgjkhis.modules.system.domain.Consult;
import com.zgjkhis.modules.system.service.ConsultService;
import com.zgjkhis.modules.system.service.mapper.ConsultMapper;
import org.springframework.data.domain.Pageable;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

// 默认不使用缓存
//import org.springframework.cache.annotation.CacheConfig;
//import org.springframework.cache.annotation.CacheEvict;
//import org.springframework.cache.annotation.Cacheable;

/**
 * @Author yzq
 * @Description 处方
 * @Date 2021/6/23 9:47
 * @Param
 * @return
 **/
@Service
//@CacheConfig(cacheNames = "user")
@Transactional(propagation = Propagation.SUPPORTS, readOnly = true, rollbackFor = Exception.class)
public class ConsultServiceImpl extends BaseServiceImpl<ConsultMapper, Consult> implements ConsultService {

    private final IGenerator generator;

    private final ConsultMapper consultMapper;

    public ConsultServiceImpl(IGenerator generator, ConsultMapper consultMapper) {
        this.generator = generator;
        this.consultMapper = consultMapper;
    }

    @Override
    public PageResult<ConsultDto> findAllByPageable(ConsultQueryCriteria criteria, Pageable pageable) {
        getPage(pageable);
        PageInfo<ConsultDto> page = new PageInfo<>(consultMapper.findAllByPageable(criteria));
        return PageResult.data(page, ConsultDto.class);
    }
}
